package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WaterQualityMng;
import com.ruoyi.system.service.IWaterQualityMngService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 *WaterQualityMngController
 */
@Anonymous
@RestController
@RequestMapping("/system/mng")
public class WaterQualityMngController extends BaseController
{
    @Autowired
    private IWaterQualityMngService waterQualityMngService;

    /**
     * 查询水质管理列表
     */
    //@PreAuthorize("@ss.hasPermi('system:mng:list')")
    @GetMapping("/list")
    public TableDataInfo list(WaterQualityMng waterQualityMng)
    {
        startPage();
        List<WaterQualityMng> list = waterQualityMngService.selectWaterQualityMngList(waterQualityMng);
        return getDataTable(list);
    }

    /**
     * 导出水质管理列表
     */
    //@PreAuthorize("@ss.hasPermi('system:mng:export')")
    @Log(title = "水质管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WaterQualityMng waterQualityMng)
    {
        List<WaterQualityMng> list = waterQualityMngService.selectWaterQualityMngList(waterQualityMng);
        ExcelUtil<WaterQualityMng> util = new ExcelUtil<WaterQualityMng>(WaterQualityMng.class);
        util.exportExcel(response, list, "水质管理数据");
    }

    /**
     * 获取水质管理详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:mng:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(waterQualityMngService.selectWaterQualityMngById(id));
    }

    /**
     * 新增水质管理
     */
    //@PreAuthorize("@ss.hasPermi('system:mng:add')")
    @Log(title = "水质管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WaterQualityMng waterQualityMng)
    {
        return toAjax(waterQualityMngService.insertWaterQualityMng(waterQualityMng));
    }

    /**
     * 修改水质管理
     */
    //@PreAuthorize("@ss.hasPermi('system:mng:edit')")
    @Log(title = "水质管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WaterQualityMng waterQualityMng)
    {
        return toAjax(waterQualityMngService.updateWaterQualityMng(waterQualityMng));
    }

    /**
     * 删除水质管理
     */
    //@PreAuthorize("@ss.hasPermi('system:mng:remove')")
    @Log(title = "水质管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(waterQualityMngService.deleteWaterQualityMngByIds(ids));
    }
}
